﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Ue.CQRS.Tests.Attribute
{
    /// <summary>
    /// EventHandleAttribute 的摘要说明
    /// </summary>
    [TestClass]
    public class EventHandleAttributeTests
    {
        #region Event Name

        [TestMethod]
        public void NameIsEmpty()
        {
            var eventHandleAttrbiute = new EventHandlerAttribute();

            var self = this.GetType().GetMethods().FirstOrDefault(item => item.Name.Equals("NameIsEmpty"));

            // NameIsEmpty  + Event
            Assert.AreEqual("NameIsEmptyEvent", eventHandleAttrbiute.GetEventName(self));
        }

        [TestMethod]
        public void NameRemoveHandle()
        {
            var eventHandleAttrbiute = new EventHandlerAttribute();

            var self = this.GetType().GetMethods().FirstOrDefault(item => item.Name.Equals("NameRemoveHandle"));
            // NameRemove - Handle  + Event
            Assert.AreEqual("NameRemoveEvent", eventHandleAttrbiute.GetEventName(self));
        }

        [TestMethod]
        public void SetEventName()
        {
            var eventHandleAttrbiute = new EventHandlerAttribute("SelfSetName");

            var self = this.GetType().GetMethods().FirstOrDefault(item => item.Name.Equals("SetEventName"));
            
            Assert.AreEqual("SelfSetName", eventHandleAttrbiute.GetEventName(self));
        }

        #endregion
    }
}
